package com.mt.api.modules.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mt.api.modules.domain.ProductDetail;
import com.mt.api.modules.manager.IProductDetailManager;
import com.mt.api.modules.mapper.ProductDetailMapper;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: plover
 * @Date: 2022-05-06
 * @Description:
 */
@Component
public class ProductDetailManagerImpl extends ServiceImpl<ProductDetailMapper, ProductDetail> implements IProductDetailManager {


    @Override
    public List<ProductDetail> getListByProductIds(List<Integer> productIds) {
        LambdaQueryWrapper<ProductDetail> wrapper = Wrappers.lambdaQuery();
        wrapper.in(ProductDetail::getProductId, productIds)
                .orderByDesc(ProductDetail::getId);
        return baseMapper.selectList(wrapper);
    }

    @Override
    public List<ProductDetail> getListByProductId(Integer productId) {
        LambdaQueryWrapper<ProductDetail> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(ProductDetail::getProductId, productId)
                .orderByDesc(ProductDetail::getId);
        return baseMapper.selectList(wrapper);
    }
}
